package webservice.axis2.util;

import javax.xml.namespace.QName;

import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;

public class Axis2Util {
	
	public static Object callWebService(String url,String schemaNamespace,String method,Class returnClass,Object[] paraValueArr){
		Object ret = null;
		try {     	
			RPCServiceClient serviceClient = new RPCServiceClient();

			Options options = serviceClient.getOptions();
			EndpointReference targetEPR = new EndpointReference(url);
			options.setTo(targetEPR);

			QName qName = new QName(schemaNamespace,method);
			
			Class[] returnClassArr = new Class[] { returnClass };

			Object[] response = serviceClient.invokeBlocking(qName,paraValueArr, returnClassArr);
			ret = response[0];

		}catch (AxisFault e) {
			e.printStackTrace();
		}
		return ret;
	}

}
